<#-- 
     Description:7996商品新增和修改页面
     Author：Wangxuegang
     Date：2013-04-25
-->
<#include "../template/template_editPage.ftl">
<@edit title="7996产品管理">
	<#if (product_id)??>
        <#assign isEdit = true />
    <#else>
        <#assign isAdd = true />
    </#if>
<body class="input">
    <script type="text/javascript">
    	$().ready(function () {
        var $validateErrorContainer = $("#validateErrorContainer");
        var $validateErrorLabelContainer = $("#validateErrorContainer ul");
        var $validateForm = $("#inputForm");
        var $tab = $("#tab");

        // Tab效果
        $tab.tabs(".tabContent", {
            tabs:"input"
        });

    	// 表单验证
        $validateForm.validate({
            errorContainer:$validateErrorContainer,
            errorLabelContainer:$validateErrorLabelContainer,
            wrapper:"li",
            errorClass:"validateError",
            ignoreTitle:true,
            rules:{
                "snnsGoodsInfo.product_id":{
                    required:true
                },
                "snnsGoodsInfo.product_name":{
                    required:true
                },
                "snnsGoodsInfo.product_parvalue":{
                    required:true
                },
                "snnsGoodsInfo.product_price":{
                    required:true
                }
            },
            messages:{
                "snnsGoodsInfo.product_id":{
                    required:"产品编号不能为空！"
                },
                "snnsGoodsInfo.product_name":{
                    required:"产品名称不能为空！"
                },
                "snnsGoodsInfo.product_parvalue":{
                    required:"产品面值不能为空！"
                },
                "snnsGoodsInfo.product_price":{
                    required:"产品进价不能为空！"
                }
            },
            submitHandler:function (form) {
                form.submit();
            }
	        });
	        <#if actionErrors?? && (actionErrors?size > 0)>
	            $.dialog({type:"warn", content:"<#list errorMessages as list>${list}<br></#list>",
	                modal:true, autoCloseTime:3000});
	        </#if>
	    	$("#submitId").click(function () {
	            var validatorPrice = check2();
	            return  validatorPrice;
	        });
    	});

    	 function check1(){
    	 	$("#priceSpan").html("");
             var e = /^(([1-9]\d*)|\d)(\.\d{1,3})?$/;
    	 	var blsx = $("#product_parvalue").val();
    	 	if (!e.test(blsx)) {
	            $("#priceSpan").html('面值格式不正确！(例：0.000)');
	            return false;
            }else {
                return true;
            }
    	 }

    	function check2() {
    		 $("#priceSpan2").html('');
            var e = /^(([1-9]\d*)|\d)(\.\d{1,3})?$/;
             var blsx = $("#product_price").val();
    		  if (!e.test(blsx)) {
		        $("#priceSpan2").html('价格格式不正确！(例：0.000)');
		        return false;
       		  }else {
                   return true;
              }
    	}
    </script>

    <div class="body">
    	 <div class="inputBar">
      		  <h1><span class="icon">&nbsp;</span><#if isAdd??>添加7996产品信息<#else>编辑7996产品信息</#if></h1>
    	</div>
    	<div style="display: none;" id="validateErrorContainer" class="validateErrorContainer">
	        <div class="validateErrorTitle">以下信息填写有误,请重新填写</div>
	        <ul></ul>
    	</div>
    	<form id="inputForm" class="validate"
          action="
          <#if isAdd??>
             ${web_base}/game/snns_goods!save.htm
          <#else>
             ${web_base}/game/snns_goods!edit.htm
          </#if>"
          method="post">
             <input type="hidden" name="proId" value="${proId!}" />
       		 <input type="hidden" name="product_name" value="${product_name!}" />

          	<ul class="tab">
	            <li>
	                <input type="button" value="基本信息" hidefocus="true"/>
	            </li>
       	    </ul>
          <table class="inputTable tabContent">
          <#if isAdd??>
          	<tr>
                <th>
                       产品编码:
                </th>
                <td>
                    <input type="text" name="snnsGoodsInfo.product_id" class="formText {required: true}" value=""/>
                    <label class="requireField">*</label>
                </td>
            </tr>
            <tr>
                <th>
                      产品名称:
                </th>
                <td>
                    <input type="text" name="snnsGoodsInfo.product_name" class="formText {required: true}" value=""/>
                    <label class="requireField">*</label>
                </td>
            </tr>
            <tr>
                <th>
                    产品面值:(元)
                </th>
                <td>
                    <input type="text" id="product_parvalue" name="snnsGoodsInfo.product_parvalue"
                           class="formText {required: true}" value="" onblur="check1()"/>
                    <span id="priceSpan" style="color: red;"></span>
                    <label class="requireField">*</label>
                </td>
           </tr>
           <tr>
                <th>
                     产品进价:(元)
                </th>
                <td>
                    <input type="text" id="product_price" name="snnsGoodsInfo.product_price"
                           class="formText {required: true}" value="" onblur="check2()"/>
                    <span id="priceSpan2" style="color: red;"></span>
                    <label class="requireField">*</label>
                </td>
            </tr>
          <#else>
          		<#if snnsGoodsInfo??>
          			<input type="hidden" name="snnsGoodsInfo.product_parvalue" value="${snnsGoodsInfo.product_parvalue!}"/>
                      <input type="hidden" name="snnsGoodsInfo.id" value="${snnsGoodsInfo.id!}"/>
	          		<tr>
	                    <th>
	                          产品编码:
	                    </th>
	                    <td>
	                        ${snnsGoodsInfo.product_id!}
	                    </td>
	                </tr>
	                <tr>
	                    <th>
	                        产品名称:
	                    </th>
	                    <td>
	                        ${snnsGoodsInfo.product_name!}
	                    </td>
	                </tr>
          			<tr>
	                    <th>
	                        产品进价:(元)
	                    </th>
	                    <td>
	                        <input type="text" id="product_price" name="snnsGoodsInfo.product_price"
	                               class="formText {required: true}" value="${snnsGoodsInfo.product_price!}"
	                               onblur="check2()"/>
	                        <span id="priceSpan2" style="color: red;"></span>
	                    </td>
                   </tr>
          		</#if>
          	</#if>
          </table>
          <div class="buttonArea">
            <input type="submit" id="submitId" class="formButton"
                  <#if isAdd??>
                       value="添  加"
                  <#else>
                       value="更  新"
                  </#if>
                  hidefocus="true"/>
            &nbsp;&nbsp;&nbsp;&nbsp;
            <input type="button" class="formButton" onclick="window.history.back(); return false;" value="返  回"
                   hidefocus="true"/>
         </div>
    	</form>
	</div>
</body>
</@edit>
